package com.admin.business.portalWebsite.venusHouseRentSellSeePeople;

import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 房屋租售查看联系人付款记录表
 * @create: 2023-11-21 14:18:29
 **/
@Service("venusHouseRentSellSeePeopleService")
@Slf4j
public class VenusHouseRentSellSeePeopleService{

    @Resource
    VenusHouseRentSellSeePeopleDao venusHouseRentSellSeePeopleDao;

    /**
     * 添加房屋租售查看联系人付款记录表,获取id数据
     *
     * @param cdoRequest - id:主键id
     *                   - project_id:项目id
     *                   - vhrs_id:租售id
     *                   - user_id:用户id
     *                   - payment_number:支付单号
     *                   - payment_money:支付金额
     *                   - payment_state:支付状态1.未支付2.已支付
     *                   - update_time:更新时间
     *                   - begin_time:创建时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return addVenusHouseRentSellSeePeople(CDO cdoRequest) {
        venusHouseRentSellSeePeopleDao.addVenusHouseRentSellSeePeople(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("id")) {
            cdoResult.set("id", cdoRequest.get("id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据id，更新房屋租售查看联系人付款记录表数据
     *
     * @param cdoRequest - id:主键id
     *                   - project_id:项目id
     *                   - vhrs_id:租售id
     *                   - user_id:用户id
     *                   - payment_number:支付单号
     *                   - payment_money:支付金额
     *                   - payment_state:支付状态1.未支付2.已支付
     *                   - update_time:更新时间
     *                   - begin_time:创建时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return updateVenusHouseRentSellSeePeopleById(CDO cdoRequest) {
        venusHouseRentSellSeePeopleDao.updateVenusHouseRentSellSeePeopleById(cdoRequest);
        return Return.SUCCESS;
    }

    /**
     * 根据id，删除房屋租售查看联系人付款记录表数据
     *
     * @param cdoRequest - id:主键id
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return deleteVenusHouseRentSellSeePeopleById(CDO cdoRequest){
        int count = venusHouseRentSellSeePeopleDao.deleteVenusHouseRentSellSeePeopleById(cdoRequest.getLong("id"));
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除房屋租售查看联系人付款记录表数据
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return deleteVenusHouseRentSellSeePeople(CDO cdoRequest) {
        int count = venusHouseRentSellSeePeopleDao.deleteVenusHouseRentSellSeePeople(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取房屋租售查看联系人付款记录表数据
     *
     * @param cdoRequest - id:主键id
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return getVenusHouseRentSellSeePeopleById(CDO cdoRequest) {
        CDO cdoMapperResult = venusHouseRentSellSeePeopleDao.getVenusHouseRentSellSeePeopleById(cdoRequest.getLong("id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取房屋租售查看联系人付款记录表数据列表
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return getVenusHouseRentSellSeePeopleListPage(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusHouseRentSellSeePeopleDao.getVenusHouseRentSellSeePeopleListPage(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusHouseRentSellSeePeopleDao.getVenusHouseRentSellSeePeopleCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
    /**
     * 根据混合条件，获取房屋租售查看联系人付款记录表数据列表
     *
     * @param cdoRequest - id:主键id
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return getVenusHouseRentSellSeePeopleListPageByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusHouseRentSellSeePeopleDao.getVenusHouseRentSellSeePeopleListPageByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusHouseRentSellSeePeopleDao.getVenusHouseRentSellSeePeopleCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
}
